use crate::core::Executor;
use crate::component;
use std::path::PathBuf;

#[derive(Default, Debug)]
pub struct Build {}

impl Executor for Build {
    fn execute(&mut self, current_path: PathBuf, args: Vec<String>) {
        let mut path = String::from(current_path.to_str().unwrap());
        for i in 0..args.len() {
            if args[i].eq("--from") && i + 1 < args.len() {
                path = String::from(&args[i + 1]);
            }
        }
        println!(" -- execute build from {}", &path);
        if let Err(e) = component::exec(&path) {
            panic!(" -- [ERROR] {:?}", e);
        };
    }
}

impl Build {}